package com.us.usws.service.ro.impl;

import java.util.ArrayList;
import java.util.List;

import com.us.usws.common.EpServerConstants;
import com.us.usws.common.SiteConstants;
import com.us.usws.dao.EpMscInfoDAO;
import com.us.usws.model.domain.epserver.EpMscServerInfo;
import com.us.usws.service.ro.EpMscInfoROService;

public class EpMscInfoROServiceImpl implements EpMscInfoROService {

	private EpMscInfoDAO dao = new EpMscInfoDAO();

	@Override
	public EpMscServerInfo getVideoMeetingServerInfo() {
		EpMscServerInfo ret = dao.getMscServerInfoByRole(EpServerConstants.EP_MSC_INFO_ROLE_MVIDEO);
		if (ret == null) {
			ret = dao.getMscServerInfoByRole(EpServerConstants.EP_MSC_INFO_ROLE_SVIDEO);
		}
		return ret;
	}

	@Override
	public EpMscServerInfo getWhiteBoardServerInfo() {
		EpMscServerInfo ret = dao.getMscServerInfoByRole(EpServerConstants.EP_MSC_INFO_ROLE_MWB);
		if (ret == null) {
			ret = dao.getMscServerInfoByRole(EpServerConstants.EP_MSC_INFO_ROLE_SWB);
		}
		return ret;
	}

	@Override
	public EpMscServerInfo getServerInfoByServerType(int serverType) {
		if (serverType == SiteConstants.DSID_MEETING_SERVER_TYPE_VIDEO) {
			return getVideoMeetingServerInfo();
		} else {
			return getWhiteBoardServerInfo();
		}
	}

	@Override
	public List<EpMscServerInfo> getMeetingServerInfos() {
		List<EpMscServerInfo> ret = new ArrayList<EpMscServerInfo>();
		ret.add(getVideoMeetingServerInfo());
		ret.add(getWhiteBoardServerInfo());
		return ret;
	}

}
